-- Entity base implementation, that all entities should derive from

prototype.Base_Entity = {id = -1, alive = true, type = entity_types.entity}

-- Entities must instanciate all of these hooked methods
-- this inheritance is all handled by the entity factory
function prototype.Base_Entity:OnCreate ( o )
   io.stdout:write("A base entity was instanciated: ID ", tostring(self.id), "\n")
   self.alive = true
   if(self.id == 0) then
      shared_entity_factory.Create("Base_Entity")
   end
end

function prototype.Base_Entity:OnDestroy ()
   io.stdout:write("Bam! Destroyed object ", tostring(self.id))
   shared_entities[self.id] = nil -- Hand this over to the garbage collector
end

function prototype.Base_Entity:OnThink ()
   --This function gets executed 33 times a second, or something like that
end

--Call this when you want to create a new subclass prototype deriving
--functionality from entity (I guess EVERYTHING calls this derivation)
function prototype.Base_Entity:Derive( o )
   o = o or {}
   setmetatable(o, self)
   self.__index = self
   return o
end
